using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Threading;
using General.Control.Avalonia.Demo.ViewModels;

namespace General.Control.Avalonia.Demo.Views;

public partial class MainWindow : Window
{
    MainWindowViewModel _viewModel => DataContext as MainWindowViewModel;

    public MainWindow()
    {
        InitializeComponent();
      
    }

    private void Control_OnLoaded(object? sender, RoutedEventArgs e)
    {
        _viewModel.MaxDate = DateTime.Now.AddDays(6);
        
        _viewModel.MinDate = DateTime.Now.AddDays(-6);

        DispatcherTimer.RunOnce(() =>
        {
            _viewModel.MaxDate = DateTime.Now.AddDays(20);
            _viewModel.MinDate = DateTime.Now.AddDays(-40);
            Console.WriteLine($"新的最小日期:{_viewModel.MinDate}");
        }, TimeSpan.FromSeconds(5));

        Console.WriteLine($"最小日期:{_viewModel.MinDate}");
        
    }
}